package com.day05.homework;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

class Student {
    private String stuName;
    private Integer stuAge;
    private Date birth;

    public Student() {
    }

    public Student(String stuName, Integer stuAge, Date birth) {
        this.stuName = stuName;
        this.stuAge = stuAge;
        this.birth = birth;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public Integer getStuAge() {
        return stuAge;
    }

    public void setStuAge(Integer stuAge) {
        this.stuAge = stuAge;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuName='" + stuName + '\'' +
                ", stuAge=" + stuAge +
                ", birth=" + birth +
                '}';
    }
}

/**
 * 接受用户输入姓名，年龄，生日；
 * 转换类型，设置到Stu对象中，并打印最终结果
 */
public class DateExercise {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Student stu = new Student();
        System.out.println("-- 输入姓名");
        stu.setStuName(sc.nextLine());
        System.out.println("-- 输入年龄");
        stu.setStuAge(Integer.parseInt(sc.nextLine()));
        System.out.println("-- 输入生日");
        try {
            stu.setBirth(new SimpleDateFormat("yyyy MM dd").parse(sc.nextLine()));
        } catch (ParseException e) {
            e.printStackTrace();
        }

        System.out.println(stu.toString());
    }

}
